package com.common.emums;

import com.common.ErrorCodeEnum;
import com.common.exception.BusinessException;

/**
 * @Author: zql
 * @Description: 用户状态
 * @Data: 9:16 2021/7/29
 */
public enum Status {
    //枚举值
    OK((byte) 0, "正常"),
    DISABLE((byte) 1, "异常");

    private final Byte code;
    private final String info;

    Status(Byte code, String info) {
        this.code = code;
        this.info = info;
    }

    public static String info(Byte code){
      for(Status dataStatus: Status.values()){
          if(dataStatus.getCode().equals(code)){
              return dataStatus.getInfo();
          }
      }
      throw new BusinessException(ErrorCodeEnum.DATA_STATUS_FAILED.setParam("code:"+code));
    }

    public boolean equals(Byte code){
        if(this.code.equals(code)) {
            return true;
        }
        return false;
    }

    public static boolean contains(Byte code){
        if(code >=0 && code<=2){
            return true;
        }
        return false;
    }



    public Byte getCode() {
        return code;
    }

    public String getInfo() {
        return info;
    }
}
